<?php

namespace JLPay\Models\Ledger\BalanceSplit;

/**
 * 接收方信息
 */
class Receiver
{
    protected ?string $revMchId = null;
    protected ?string $amount = null;
    protected ?string $description = null;
    protected ?string $result = null;
    protected ?string $failReason = null;
    protected ?string $detailId = null;
    protected ?string $createTime = null;
    protected ?string $finishTime = null;

    /**
     * 构造函数
     *
     * @param array|null $receiverArray
     */
    public function __construct(?array $receiverArray = null)
    {
        if ($receiverArray) {
            $this->revMchId = $receiverArray['rev_mch_id'] ?? null;
            $this->amount = $receiverArray['amount'] ?? null;
            $this->description = $receiverArray['description'] ?? null;
            $this->result = $receiverArray['result'] ?? null;
            $this->failReason = $receiverArray['fail_reason'] ?? null;
            $this->detailId = $receiverArray['detail_id'] ?? null;
            $this->createTime = $receiverArray['create_time'] ?? null;
            $this->finishTime = $receiverArray['finish_time'] ?? null;
        }
    }

    /**
     * 获取接收方商户号
     *
     * @return string|null
     */
    public function getRevMchId(): ?string
    {
        return $this->revMchId;
    }

    /**
     * 获取金额
     *
     * @return string|null
     */
    public function getAmount(): ?string
    {
        return $this->amount;
    }

    /**
     * 获取描述
     *
     * @return string|null
     */
    public function getDescription(): ?string
    {
        return $this->description;
    }

    /**
     * 获取结果
     *
     * @return string|null
     */
    public function getResult(): ?string
    {
        return $this->result;
    }

    /**
     * 获取失败原因
     *
     * @return string|null
     */
    public function getFailReason(): ?string
    {
        return $this->failReason;
    }

    /**
     * 获取明细ID
     *
     * @return string|null
     */
    public function getDetailId(): ?string
    {
        return $this->detailId;
    }

    /**
     * 获取创建时间
     *
     * @return string|null
     */
    public function getCreateTime(): ?string
    {
        return $this->createTime;
    }

    /**
     * 获取完成时间
     *
     * @return string|null
     */
    public function getFinishTime(): ?string
    {
        return $this->finishTime;
    }

    /**
     * 转换为数组
     *
     * @return array
     */
    public function toArray(): array
    {
        return [
            'rev_mch_id' => $this->revMchId,
            'amount' => $this->amount,
            'description' => $this->description,
            'result' => $this->result,
            'fail_reason' => $this->failReason,
            'detail_id' => $this->detailId,
            'create_time' => $this->createTime,
            'finish_time' => $this->finishTime,
        ];
    }
} 